using Senparc.Weixin.HttpUtility;
using System;
using System.IO;
using System.Text;
namespace Senparc.Weixin.MP.AdvancedAPIs
{
	public static class TenPayV3
	{
		public static string Unifiedorder(string data, int timeOut = 10000)
		{
			string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, timeOut, false);
		}
		public static string NativePay(string appId, string timesTamp, string mchId, string nonceStr, string productId, string sign)
		{
			string format = "weixin://wxpay/bizpayurl?sign={0}&appid={1}&mch_id={2}&product_id={3}&time_stamp={4}&nonce_str={5}";
			return string.Format(format, new object[]
			{
				sign,
				appId,
				mchId,
				productId,
				timesTamp,
				nonceStr
			});
		}
		public static string OrderQuery(string data)
		{
			string url = "https://api.mch.weixin.qq.com/pay/orderquery";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
		public static string CloseOrder(string data)
		{
			string url = "https://api.mch.weixin.qq.com/pay/closeorder";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
		public static string RefundQuery(string data)
		{
			string url = "https://api.mch.weixin.qq.com/pay/refundquery";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
		public static string DownloadBill(string data)
		{
			string url = "https://api.mch.weixin.qq.com/pay/downloadbill";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
		public static string ShortUrl(string data)
		{
			string url = "https://api.mch.weixin.qq.com/tools/shorturl";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
		public static string MicroPay(string data)
		{
			string url = "https://api.mch.weixin.qq.com/pay/micropay";
			byte[] array = (data == null) ? new byte[0] : Encoding.UTF8.GetBytes(data);
			MemoryStream memoryStream = new MemoryStream();
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return RequestUtility.HttpPost(url, null, memoryStream, null, null, null, 10000, false);
		}
	}
}
